import { ElMessage } from 'element-plus'
import router from '@/router'
import { progressClose, progressStart } from '@/hooks/use-permission'
import { useBasicStore } from '@/store/basic'
import { langTitle } from '@/hooks/use-common'
import { asyncRoutes } from '@/router/index'
import BidEvaluation from '@/router/modules/bid-evaluation'
import CommonFunctions from '@/router/modules/common-functions'

//路由进入前拦截
//to:将要进入的页面 vue-router4.0 不推荐使用next()
const whiteList = ['/404', '/401'] // no redirect whitelist
router.beforeEach(async (to) => {
  progressStart()
  document.title = langTitle(to.meta?.title) // i18 page title
  const { setFilterAsyncRoutes, token } = useBasicStore()
  if (token) {
    setFilterAsyncRoutes([])
    return true
  } else {
    ElMessage.error('无登录信息，请从统一登录进入！')
    return false
  }
})
//路由进入后拦截
router.afterEach(() => {
  progressClose()
})
